<?php
/**
 * urForum
 *
 * @package urForum
 * @author urForum Team http://urforum.googlecode.com
 * @copyright 2011 Nick "Ha^2"
 * @license "license.txt" (3-Clause BSD)
 *
 * @version 0.1 Alpha
 *
 * urForum is a completely unendorsed, unaffiliated fork of the Simple Machines Forum (SMF) software,
 * the license of which can be found in the attached smflicense.txt file.
 */

if (!defined('SMF'))
	die('Hacking Attempt...');

function summary_memberFriends($memID)
{
	global $smcFunc, $memberContext;
	$request = $smcFunc['db_query']('', '
		SELECT id_member_one, id_member_two, time_stamp
		FROM {db_prefix}friends
		WHERE id_member_one = {int:memID} OR id_member_two = {int:memID}
		ORDER BY RAND() LIMIT 8',
		array(
			'memID' => (int) $memID,
		)
	);
	$return_array = array();
	while ($data = $smcFunc['db_fetch_assoc']($request))
	{
		if ($data['id_member_one'] != $memID && $data['id_member_two'] == $memID)
			$friend_id = $data['id_member_one'];
		else
			$friend_id = $data['id_member_two'];

		if (!isset($memberContext[$friend_id]))
		{
			loadMemberData(array($friend_id), false, 'normal');
			loadMemberContext($friend_id);
		}

		$return_array[$friend_id]['data'] = $memberContext[$friend_id];
		$return_array[$friend_id]['time_stamp'] = timeformat($data['time_stamp'], true, false);
	}
	$smcFunc['db_free_result']($request);
	return $return_array;
}

?>